<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="活动名称" prop="activityName">
        <el-input v-model="queryParams.activityName" placeholder="请输入活动名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="活动地址" prop="activityAddress">
        <el-input v-model="queryParams.activityAddress" placeholder="请输入活动地址" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="报名开始时间" prop="applyStartTime">
        <el-date-picker clearable v-model="queryParams.applyStartTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择报名开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="报名结束时间" prop="applyEndTime">
        <el-date-picker clearable v-model="queryParams.applyEndTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择报名结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="活动开始时间" prop="activityStartTime">
        <el-date-picker clearable v-model="queryParams.activityStartTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择活动开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="活动结束时间" prop="activityEndTime">
        <el-date-picker clearable v-model="queryParams.activityEndTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择活动结束时间">
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="最大参与人数" prop="memberMax">
        <el-input
          v-model="queryParams.memberMax"
          placeholder="请输入最大参与人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最小参与人数" prop="memberMin">
        <el-input
          v-model="queryParams.memberMin"
          placeholder="请输入最小参与人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="发布者" prop="publisher">
        <el-input
          v-model="queryParams.publisher"
          placeholder="请输入发布者"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="已报名人数" prop="applyMembers">
        <el-input
          v-model="queryParams.applyMembers"
          placeholder="请输入已报名人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="活动CO2" prop="activityCo2">
        <el-input
          v-model="queryParams.activityCo2"
          placeholder="请输入活动CO2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="是否可见" prop="isVisible">
        <template slot="label">
          <span>
            是否可见
            <el-tooltip class="item" effect="dark" content="0-不可见，1-仅组织可见，2-所有人可见" placement="top">
              <i class="el-icon-question"></i>
            </el-tooltip>
          </span>
        </template>
        <el-input v-model="queryParams.isVisible" placeholder="请输入是否可见" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="删除标识" prop="isDel">
        <template slot="label">
          <span>
            删除标识
            <el-tooltip class="item" effect="dark" content="0-正常，1-停用" placement="top">
              <i class="el-icon-question"></i>
            </el-tooltip>
          </span>
        </template>
        <el-input v-model="queryParams.isDel" clearable placeholder="请输入删除标识" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="删除标识" prop="isDel">
        <el-input
          v-model="queryParams.isDel"
          placeholder="请输入删除标识"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="扩展字段1" prop="ext1">
        <el-input
          v-model="queryParams.ext1"
          placeholder="请输入扩展字段1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="扩展字段2" prop="ext2">
        <el-input
          v-model="queryParams.ext2"
          placeholder="请输入扩展字段2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="扩展字段3" prop="ext3">
        <el-input
          v-model="queryParams.ext3"
          placeholder="请输入扩展字段3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="扩展字段4" prop="ext4">
        <el-input
          v-model="queryParams.ext4"
          placeholder="请输入扩展字段4"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="扩展字段5" prop="ext5">
        <el-input
          v-model="queryParams.ext5"
          placeholder="请输入扩展字段5"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8" style="display: flex;">
      <el-col style="justify-content: left;" :span="20">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:activity:add']">新增</el-button>
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:activity:edit']">修改</el-button>
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:activity:remove']">删除</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:activity:export']">导出</el-button>
      </el-col>
      <el-col style="justify-content: right;" class="text-right" v-show="showSearch" :span="2.5">
        <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :span="1.5"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="activityApplyList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="活动申请Id" align="center" prop="activityApplyId" />
      <el-table-column label="活动名称" align="center" prop="activityName" />
      <el-table-column align="center" label="活动宣传图片" prop="imgPath" width="100">
        <template slot-scope="scope">
          <p v-if="scope.row.imgPath == null">无图片</p>
          <image-preview v-if="scope.row.imgPath != null" :src="scope.row.imgPath" :width="50" :height="50" />
        </template>
      </el-table-column>
      <!-- <el-table-column label="活动介绍" align="center" prop="activityIntro" /> -->
      <el-table-column label="活动地址" align="center" prop="activityAddress" width="180" />
      <!-- <el-table-column label="报名开始时间" align="center" prop="applyStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报名结束时间" align="center" prop="applyEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="活动开始时间" align="center" prop="activityStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.activityStartTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="活动结束时间" align="center" prop="activityEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.activityEndTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="最大参与人数" align="center" prop="memberMax" />
      <el-table-column label="最小参与人数" align="center" prop="memberMin" /> -->
      <el-table-column label="发布者id" align="center" prop="publisher" />
      <!-- <el-table-column label="已报名人数" align="center" prop="applyMembers" /> -->
      <el-table-column label="活动CO2" align="center" prop="activityCo2" />
      <el-table-column label="是否可见" align="center" prop="isVisible" />
      <el-table-column label="删除标识" align="center" prop="isDel" />
      <!-- <el-table-column label="扩展字段1" align="center" prop="ext1" />
      <el-table-column label="扩展字段2" align="center" prop="ext2" />
      <el-table-column label="扩展字段3" align="center" prop="ext3" />
      <el-table-column label="扩展字段4" align="center" prop="ext4" />
      <el-table-column label="扩展字段5" align="center" prop="ext5" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
            v-hasPermi="['monitor:job:query']">详细</el-button>
          <el-button size="mini" type="text" icon="el-icon-check" @click="submitApply(scope.row.activityApplyId)"
            v-hasPermi="['monitor:job:query']">同意申请</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改活动申请表对话框 -->
    <el-dialog :title="title" :visible.sync="openEdit" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-form-item label="申请活动Id" prop="activityApplyId">
          <el-input v-model="form.activityApplyId" placeholder="请输入申请活动Id" />
        </el-form-item>
        <el-form-item label="活动名称" prop="activityName">
          <el-input v-model="form.activityName" placeholder="请输入活动名称" />
        </el-form-item>
        <el-form-item label="活动宣传图片" prop="imgPath">
          <image-activityApplyImg-upload v-model="form.imgPath" />
        </el-form-item>
        <el-form-item label="活动介绍">
          <editor v-model="form.activityIntro" :min-height="192" />
        </el-form-item>
        <el-form-item label="活动地址" prop="activityAddress">
          <el-input v-model="form.activityAddress" placeholder="请输入活动地址" />
        </el-form-item>
        <el-form-item label="是否可见" prop="isVisible">
          <template slot="label">
            <span>
              是否可见
              <el-tooltip class="item" effect="dark" content="0-不可见，1-仅组织可见，2-所有人可见" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.isVisible" placeholder="请输入是否可见" />
        </el-form-item>
        <el-form-item label="报名开始时间" prop="applyStartTime">
          <el-date-picker clearable v-model="form.applyStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择报名开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报名结束时间" prop="applyEndTime">
          <el-date-picker clearable v-model="form.applyEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择报名结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="活动开始时间" prop="activityStartTime">
          <el-date-picker clearable v-model="form.activityStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择活动开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="活动结束时间" prop="activityEndTime">
          <el-date-picker clearable v-model="form.activityEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择活动结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="活动奖励是否结算" prop="isSettled">
          <template slot="label">
            <span>
              活动是否结算
              <el-tooltip class="item" effect="dark" content="0-否，1-是" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.isSettled" placeholder="请输入（0-否，1-是）" />
        </el-form-item>
        <el-form-item label="最大参与人数" prop="memberMax">
          <el-input v-model="form.memberMax" placeholder="请输入最大参与人数" />
        </el-form-item>
        <el-form-item label="最小参与人数" prop="memberMin">
          <el-input v-model="form.memberMin" placeholder="请输入最小参与人数" />
        </el-form-item>
        <el-form-item label="发布者id" prop="publisher">
          <el-input v-model="form.publisher" placeholder="请输入发布者id" />
        </el-form-item>
        <el-form-item label="已报名人数" prop="applyMembers">
          <el-input v-model="form.applyMembers" placeholder="请输入已报名人数" />
        </el-form-item>
        <el-form-item label="活动CO2" prop="activityCo2">
          <el-input v-model="form.activityCo2" placeholder="请输入活动CO2" />
        </el-form-item>
        <el-form-item label="删除标识" prop="isDel">
          <template slot="label">
            <span>
              删除标识
              <el-tooltip class="item" effect="dark" content="0-正常，1-停用" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.isDel" placeholder="请输入删除标识（0-正常，1-停用）" />
        </el-form-item>
        <!-- <el-form-item label="扩展字段1" prop="isSettled">
          <el-input v-model="form.ext1" placeholder="请输入扩展字段1" />
        </el-form-item>
        <el-form-item label="扩展字段2" prop="ext2">
          <el-input v-model="form.ext2" placeholder="请输入扩展字段2" />
        </el-form-item>
        <el-form-item label="扩展字段3" prop="ext3">
          <el-input v-model="form.ext3" placeholder="请输入扩展字段3" />
        </el-form-item>
        <el-form-item label="扩展字段4" prop="ext4">
          <el-input v-model="form.ext4" placeholder="请输入扩展字段4" />
        </el-form-item>
        <el-form-item label="扩展字段5" prop="ext5">
          <el-input v-model="form.ext5" placeholder="请输入扩展字段5" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="title" :visible.sync="openView" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-form-item label="申请活动Id" prop="activityApplyId">
          <el-input v-model="form.activityApplyId" placeholder="未填入申请活动Id" readonly />
        </el-form-item>
        <el-form-item label="活动名称" prop="activityName">
          <el-input v-model="form.activityName" placeholder="未填入活动名称" readonly />
        </el-form-item>
        <el-form-item label="活动宣传图片" prop="imgPath">
          <template slot-scope="scope">
            <p v-if="form.imgPath == null">无图片</p>
            <image-preview v-if="form.imgPath != null" :src="form.imgPath" :width="50" :height="50" />
          </template>
        </el-form-item>
        <el-form-item label="活动介绍">
          <editor v-model="form.activityIntro" :min-height="192" placeholder="未填入活动介绍" readonly />
        </el-form-item>
        <el-form-item label="活动地址" prop="activityAddress">
          <el-input v-model="form.activityAddress" placeholder="未填入活动地址" readonly />
        </el-form-item>
        <el-form-item label="是否可见" prop="isVisible">
          <template slot="label">
            <span>
              是否可见
              <el-tooltip class="item" effect="dark" content="0-不可见，1-仅组织可见，2-所有人可见" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.isVisible" placeholder="未填入是否可见" readonly />
        </el-form-item>
        <el-form-item label="报名开始时间" prop="applyStartTime">
          <el-date-picker clearable v-model="form.applyStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="未填入报名开始时间" readonly>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报名结束时间" prop="applyEndTime">
          <el-date-picker clearable v-model="form.applyEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="未填入报名结束时间" readonly>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="活动开始时间" prop="activityStartTime">
          <el-date-picker clearable v-model="form.activityStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="未填入活动开始时间" readonly>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="活动结束时间" prop="activityEndTime">
          <el-date-picker clearable v-model="form.activityEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="未填入活动结束时间" readonly>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="活动奖励是否结算" prop="isSettled">
          <template slot="label">
            <span>
              活动是否结算
              <el-tooltip class="item" effect="dark" content="0-否，1-是" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.isSettled" placeholder="未填入（0-否，1-是）" readonly />
        </el-form-item>
        <el-form-item label="最大参与人数" prop="memberMax">
          <el-input v-model="form.memberMax" placeholder="未填入最大参与人数" readonly />
        </el-form-item>
        <el-form-item label="最小参与人数" prop="memberMin">
          <el-input v-model="form.memberMin" placeholder="未填入最小参与人数" readonly />
        </el-form-item>
        <el-form-item label="发布者id" prop="publisher">
          <el-input v-model="form.publisher" placeholder="未填入发布者id" readonly />
        </el-form-item>
        <el-form-item label="发布者所在组织" prop="organization"><template slot="label">
            <span>
              发布者所在组织
              <el-tooltip class="item" effect="dark" content="点击将前往“用户管理”修改" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.organization" placeholder="未填入发布者" @click.native="handleClickUser" readonly />
        </el-form-item>
        <el-form-item label="已报名人数" prop="applyMembers">
          <el-input v-model="form.applyMembers" placeholder="未填入已报名人数" readonly />
        </el-form-item>
        <el-form-item label="活动CO2" prop="activityCo2">
          <el-input v-model="form.activityCo2" placeholder="未填入活动CO2" readonly />
        </el-form-item>
        <el-form-item label="删除标识" prop="isDel">
          <template slot="label">
            <span>
              删除标识
              <el-tooltip class="item" effect="dark" content="0-正常，1-停用" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </span>
          </template>
          <el-input v-model="form.isDel" placeholder="未填入删除标识（0-正常，1-停用）" readonly />
        </el-form-item>
        <!-- <el-form-item label="扩展字段1" prop="isSettled">
          <el-input v-model="form.ext1" placeholder="请输入扩展字段1" />
        </el-form-item>
        <el-form-item label="扩展字段2" prop="ext2">
          <el-input v-model="form.ext2" placeholder="请输入扩展字段2" />
        </el-form-item>
        <el-form-item label="扩展字段3" prop="ext3">
          <el-input v-model="form.ext3" placeholder="请输入扩展字段3" />
        </el-form-item>
        <el-form-item label="扩展字段4" prop="ext4">
          <el-input v-model="form.ext4" placeholder="请输入扩展字段4" />
        </el-form-item>
        <el-form-item label="扩展字段5" prop="ext5">
          <el-input v-model="form.ext5" placeholder="请输入扩展字段5" />
        </el-form-item> -->
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { listActivityApply, getActivityApply, delActivityApply, addActivityApply, updateActivityApply, submitActivityApply } from "@/api/system/activityApply";
//引入用户信息查询
import { getUserInfo } from "@/api/system/userInfo";

export default {
  name: "ActivityApply",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 活动申请表表格数据
      activityApplyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      openEdit: false,
      openView: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        activityName: null,
        imgPath: null,
        activityIntro: null,
        activityAddress: null,
        applyStartTime: null,
        applyEndTime: null,
        activityStartTime: null,
        activityEndTime: null,
        memberMax: null,
        memberMin: null,
        publisher: null,
        applyMembers: null,
        activityCo2: null,
        isVisible: null,
        isDel: null,
        isSettled: null,
        ext2: null,
        ext3: null,
        ext4: null,
        ext5: null
      },
      result: '',
      error: '',
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询活动申请表列表 */
    async getList() {
      this.loading = true;
      const response = await listActivityApply(this.queryParams)
      this.activityApplyList = response.rows;
      this.total = response.total;
      this.loading = false;
      await this.updateOrginalization();
    },
    // 新增元素组织单位
    async updateOrginalization() {
      for (let i = 0; i < this.activityApplyList.length; i++) {
        let userInfo = await getUserInfo(this.activityApplyList[i].publisher);
        this.$set(this.activityApplyList[i], 'organization', userInfo.data.organization);
      }
    },
    handleClickUser() {
      // 这里可以弹出确认框，或者直接跳转
      this.$confirm('确定将前往“用户信息管理”修改?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        // 用户点击确认后的逻辑，例如跳转
        this.goToUserInfo();
      }).catch(() => {
        // 用户点击取消后的逻辑（如果有需要）
      });
    },
    goToUserInfo() {
      console.log("跳转到用户信息管理页面");
      this.$router.push({ path: '/tanpuhui/userInfo' });
      this.openView = false;
    },
    // 取消按钮
    cancel() {
      this.openEdit = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        activityApplyId: null,
        activityName: null,
        imgPath: null,
        activityIntro: null,
        activityAddress: null,
        applyStartTime: null,
        applyEndTime: null,
        activityStartTime: null,
        activityEndTime: null,
        memberMax: null,
        memberMin: null,
        publisher: null,
        applyMembers: null,
        activityCo2: null,
        isVisible: null,
        isDel: null,
        createTime: null,
        updateTime: null,
        isSettled: null,
        ext2: null,
        ext3: null,
        ext4: null,
        ext5: null
      };
      this.resetForm("form");
    },
    /** 详细按钮操作 */
    handleView(row) {
      this.openView = true;
      this.title = "查看活动信息管理（如需修改，请通过修改按钮进行修改）";
      this.form = row;
    },
    /** 同意申请按钮操作 */
    async submitApply(activityApplyId) {
      // this.form.activityApplyId = activityApplyId; // 赋值 activityApplyId
      const response = await new Promise((resolve, reject) => {
        return resolve(submitActivityApply(activityApplyId)); // 调用提交函数
      });
      // console.log(response);
      if (response.code === 200) {
        if (response.msg === '已同意该活动申请'){
          this.$message.success(response.msg);
        }
        else{
          this.$message.error(response.msg);
        }
      }
      else {
        this.$message.error('同意申请失败，请稍后再试！');
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.activityApplyId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.openEdit = true;
      this.title = "添加活动申请表";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const activityApplyId = row.activityApplyId || this.ids
      getActivityApply(activityApplyId).then(response => {
        this.form = response.data;
        this.openEdit = true;
        this.title = "修改活动申请表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.activityApplyId != null) {
            updateActivityApply(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.openEdit = false;
              this.getList();
            });
          } else {
            addActivityApply(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.openEdit = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const activityApplyIds = row.activityApplyId || this.ids;
      this.$modal.confirm('是否确认删除活动申请表编号为"' + activityApplyIds + '"的数据项？').then(function () {
        return delActivityApply(activityApplyIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/activityApply/export', {
        ...this.queryParams
      }, `activityApply_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
